<template>
  <bodyWrap :isShow="bodyShow" style="z-index: 99">
    <div slot="body" v-if="bodyShow">
      <searchWrap @inputValue="inputValue"></searchWrap>
      <ul class="contacts-ul" v-if="searchList.length">
        <li class="contacts-li"
            v-for="p in searchList"
            v-if="p.isBound">
          <img src="../../img/q.png" class="img-h">
          <input class="checkInput"
                 :value="p.key"
                 type="radio"
                 v-model="checked">
          <div class="txtWrap">
            <div class="name">
              {{p.title}}
            </div>
            <div class="checkIcon"></div>
          </div>
        </li>
      </ul>
    </div>
  </bodyWrap>
</template>

<script>
  import searchWrap from "../commonComponents/search.vue"
  export default {
    data() {
      return {
        bodyShow: false,
        checked: "",
        searchList: [],
        headerRightType: {},
        headerFlag: "",
        id: "",
      }
    },
    methods: {
      init() {
        let self = this;
        this.headerRightType = this.$store.state.headerRightType;
        this.headerFlag = this.$store.state.showFlag;
        _methods.headerTitleChange(111);
        _methods.headerRightShow(
          {
            val: 211,
            txt: "指派"
          }
        );
        if (!_data.teamList.length){
          _ajax.noLoading(_ajaxUrls.getSupportTeam.url,
            {},
            (ajData) => {
              _data.teamList = ajData.data;
              this.searchList = _data.teamList;
              self.bodyShow = true;
            },
            _ajaxUrls.getSupportTeam.type);
        }else {
          this.searchList = _data.teamList;
          self.bodyShow = true;
        }
      },
      inputValue(v) {
        let k = v.toString().trim();
        if (k != "") {
          this.searchList = _data.leaderList.filter((v) => {
            return v.title.indexOf(k) != -1;
          });
        } else {
          this.searchList = _data.leaderList;
        }
      },
      addEm(){
        _alert.promt((v)=>{

          _data.emSubmitData.require = v.value;

          _data.emSubmitData.groupId = this.checked;

          _ajax.withLoading(_ajaxUrls.editEmergencyDisposal.url,
            _data.emSubmitData,
            () => {
              _data.bus.$emit("emAdd",1);
              _alert.alert(() => {});
            }, _ajaxUrls.editEmergencyDisposal.type);
        },"是否确认指派",undefined,()=>{

        },"请填写处置要求");

      },
    },
    components: {
      searchWrap
    },
    created() {
      this.init();
    },
    mounted() {
      let self = this;
      _data.busInit.on_(()=>{
        self.addEm();
      });
    },
    beforeDestroy() {
      _data.busInit.off_();
      _methods.headerTitleChange(this.headerFlag, true);
      _methods.headerRightShow(this.headerRightType);
    }
  }
</script>
